cmake_minimum_required (VERSION 2.6)

PROJECT(BubblesOS CXX C ASM)

set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")

set(KINCLUDES "-DKERNEL -I. -I${CMAKE_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/lib/stdc/include -I${CMAKE_SOURCE_DIR}/lib/stdcxx/include -I${CMAKE_SOURCE_DIR}/../plsdk/plcore")

SET(LIB_C_SRC
	include/pltypes.h
	include/plconfig.h
	include/string.h
	include/ctype.h
	include/errno.h
	include/ansi.h
	include/stddef.h
	include/ctypeflags.h
	include/wchar.h
	include/assert.h
	include/string.h
	include/stdlib.h
	include/stdio.h
	include/limits.h
	include/setjmp.h
	include/iso646.h
	include/stdbool.h
	include/stdarg.h
	include/math.h
    include/float.h
	include/sys/cdefs.h
	src/string/strlen.cpp
	src/string/strnlen.cpp
	src/string/strcpy.cpp
	src/string/strncpy.cpp
	src/string/strcmp.cpp
	src/string/strncmp.cpp
	src/string/strcat.cpp
	src/string/strncat.cpp
	src/string/strchr.cpp
	src/string/strrchr.cpp
	src/string/strtoul.cpp
	src/string/memset.cpp
	src/string/wmemset.cpp
	src/string/dmemset.cpp
	src/string/memcpy.cpp
	src/string/memmove.cpp
	src/string/memcmp.cpp
	src/string/memchr.cpp
	src/string/strcoll.cpp
	src/string/strcspn.cpp
	src/string/strerror.cpp
	src/string/strpbrk.cpp
	src/string/strspn.cpp
	src/string/strstr.cpp
	src/string/strtok.cpp
	src/string/strxfrm.cpp
	src/string/errnostring.cpp
	src/string/strchr.c
	src/string/strrchr.c
	src/string/memchr.c
	src/string/strstr.c
	src/string/strpbrk.c
	src/stdlib/skip_atoi.cpp
	src/stdlib/number.cpp
	src/stdlib/eaddr.cpp
	src/stdlib/iaddr.cpp
	src/stdlib/cfltcvt.cpp
	src/stdlib/forcdecpt.cpp
	src/stdlib/cropzeros.cpp
	src/stdlib/flt.cpp
	src/stdlib/cvt.cpp
	src/stdlib/ecvt.cpp
	src/stdlib/ecvtbuf.cpp
	src/stdlib/fcvt.cpp
	src/stdlib/fcvtbuf.cpp
    src/stdlib/strtod.cpp
    src/stdlib/atof.cpp
    src/stdlib/atoi.cpp
    src/stdlib/atol.cpp
    src/stdlib/strtol.cpp
    src/stdlib/strtoul.cpp
    src/stdlib/strtoi.cpp
	src/math/modf.cpp
	src/math/modf.c
	src/math/fabs.cpp
	src/math/fabs.c
	src/stdio/vsprintf.cpp
	src/stdio/sprintf.cpp
	src/stdlib/flt.cpp
	src/setjmp/setjmp.s
	src/ctype/ctypeflags.c
	src/ctype/ctypelower.c
	src/ctype/ctypeupper.c
	src/ctype/isalnum.c
	src/ctype/isalpha.c
	src/ctype/isascii.c
	src/ctype/iscntrl.c
	src/ctype/isdigit.c
	src/ctype/isgraph.c
	src/ctype/islower.c
	src/ctype/isprint.c
	src/ctype/ispunct.c
	src/ctype/isspace.c
	src/ctype/isupper.c
	src/ctype/unicode.c
    src/ctype/isxdigit.c
    src/ctype/toupper.c
)

add_library( libc STATIC
	${LIB_C_SRC}
)

#add_library( c SHARED
#	${LIB_C_SRC}
#)

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/plconfig.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/plconfig.h)

SET(CMAKE_CXX_COMPILE_OBJECT "${gplusplus} ${KFLAGS} ${WFLAGS} ${OPTIMIZEFLAGS} ${KINCLUDES} -g3 -c -o <OBJECT> <SOURCE>")
SET(CMAKE_C_COMPILE_OBJECT "${gcc} ${KCFLAGS} ${WFLAGS} ${OPTIMIZEFLAGS} ${KINCLUDES} -g3 -c -o <OBJECT> <SOURCE>")
SET(CMAKE_ASM_COMPILE_OBJECT "nasm -f elf <FLAGS> -o <OBJECT> <SOURCE>")
SET(CMAKE_AR "${gar}")
SET(CMAKE_RANLIB "${granlib}")
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> r  <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
SET(CMAKE_CXX_ARCHIVE_CREATE ${CMAKE_C_ARCHIVE_CREATE})
SET(CMAKE_CXX_ARCHIVE_APPEND ${CMAKE_C_ARCHIVE_APPEND})
SET(CMAKE_CXX_ARCHIVE_FINISH ${CMAKE_C_ARCHIVE_FINISH})
